package com.shenmazong.clone;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @program: server-java-demo
 * @description: Hero
 * @author: 亮子说编程
 * @create: 2020-10-16 08:58
 **/

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Hero implements Cloneable {
    private String heroName;
    private Integer heroAge;

    private HeroSkill heroSkill;

    @Override
    public Object clone() throws CloneNotSupportedException {
        //return super.clone();
        Hero hero = (Hero)super.clone();
        HeroSkill skill = (HeroSkill)heroSkill.clone();
        hero.setHeroSkill(skill);

        return hero;
    }
}
